<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>添加或编辑界面</title>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/theme/theme.css"/>
</head>
<style type="text/css">
    .layui-input-inline{width:100%;height:40px;line-height:40px;}
    table tr td .layui-form-select dl {
        top: 40px;
         min-width:calc(100% + 20px);
         left:-10px;
    }
    .cy-uploadpic-ctn{height: 205px!important;}
</style>
<body>
<div class="wrap-container clearfix">
    <div class="column-content-detail" >
        <form class="layui-form">
        <div class="wxyy--table-title">${enrollmentRelease.name}</div>
        <div class="wxyy-item-tab-ctn" id="zzzs-txt">
            <div class="wxyy-tab-list-tit">基本信息</div>
            <table class="wxyy-item-table" cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td>名字</td>
                    <td><input type="text" class="wxyy-tab-input" lay-verify="required" placeholder="请输入" name="name" id="name" value="${enrollmentStuinfo.name}" autocomplete="off" ></td>
                    <td>性别</td>
                    <td><div class="layui-input-inline">
                        <select name="sex" id="sex" lay-verify="required"></select>
                    </div></td>
                   <!-- <input type="text" class="" placeholder="请输入">-->
                    <!--<td rowspan="5"  class="wxyy-mrtx" id="pic"></td>-->
                    <td rowspan="5"  class="layui-input-block cy-uploadpic-ctn wxyy-mrtx" id="pic"></td>
                </tr>
                <tr>
                    <td>政治面貌</td>
                    <td><div class="layui-input-inline">
                        <select name="politicalStatus" id="politicalStatus" lay-verify="required"></select>
                    </div></td>
                    <td>民族</td>
                    <td><div class="layui-input-inline">
                        <select name="nationality" id="nationality" lay-verify="required"></select>
                    </div></td>
                </tr>
                <tr>
                    <td>户口类型</td>
                    <td><div class="layui-input-inline">
                        <select name="accountType" id="accountType" lay-verify="required" value=""></select>
                    </div></td>
                    <td>联系电话</td>
                    <td><input type="text" class="wxyy-tab-input" placeholder="请输入" lay-verify="phone" autocomplete="off"  name="phone" id="phone" value="${enrollmentStuinfo.phone}"></td>
                </tr>
                <tr>
                    <td>身份证号码</td>
                    <td><input type="text" class="wxyy-tab-input" placeholder="请输入" lay-verify="card" autocomplete="off"  name="card" id="card" value="${enrollmentStuinfo.card}"></td>
                    <td>毕业学校</td>
                    <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off"  name="school" id="school" value="${enrollmentStuinfo.school}"></td>
                </tr>
                <tr>
                    <td>学校所在区（县）</td>
                    <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off"  name="schoolPlace" id="schoolPlace" value="${enrollmentStuinfo.schoolPlace}"></td>
                    <td>户口所在地</td>
                    <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off"  name="accountPlace" id="accountPlace" value="${enrollmentStuinfo.accountPlace}"></td>
                </tr>
                <tr>
                    <td>考生中考报名号<br><span style="font-size:12px;color:#999">（准考证号）</span></td>
                    <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off"  name="testNum" id="testNum" value="${enrollmentStuinfo.testNum}"></td>
                    <td>邮政编码</td>
                    <td colspan="2"><input type="text" class="wxyy-tab-input" lay-verify="digital" placeholder="请输入" autocomplete="off"  name="postNum" id="postNum" value="${enrollmentStuinfo.postNum}"></td>
                </tr>
                <tr>
                    <td>所在年级总人数</td>
                    <td><input type="text" class="wxyy-tab-input" placeholder="请输入" lay-verify="digital" autocomplete="off"  name="classNum" id="classNum" value="${enrollmentStuinfo.classNum}"></td>
                    <td>所在班级总人数</td>
                    <td colspan="2"><input type="text" class="wxyy-tab-input" placeholder="请输入" lay-verify="digital" autocomplete="off" name="gradeNum" id="gradeNum"  value="${enrollmentStuinfo.gradeNum}"></td>
                </tr>
                <tr>
                    <td>详细通讯地址及联系人</td>
                    <td colspan="4"><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off"  name="place" id="place"  value="${enrollmentStuinfo.place}"></td>
                </tr>
            </table>
            <div class="wxyy-tab-add" >
                <div class="wxyy-tab-list-tit">家庭信息</div>
                <table cellpadding="0" cellspacing="0" width="100%" class="wxyy-table" id="home">
                    <thead>
                    <tr>
                        <th>姓名</th>
                        <th>称谓</th>
                        <th>工作单位</th>
                        <th>职位</th>
                        <th>手机</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <#if (homeinfoList?? && (homeinfoList?size>0))>
                            <#list homeinfoList as hList>
                                <tr>
                                <input type="hidden" value="${hList.id}">
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off"  name="name" value="${hList.name}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off"  name="title" value="${hList.title}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off"  name="workPlace" value="${hList.workPlace}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off"  name="position" value="${hList.position}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off" lay-verify="phone" name="phone" value="${hList.phone}"></td>
                                <td>
                                    <div class="operate-btn-ctn"><a class="delebtn" onclick="delTr(this)">删除</a></div>
                                </td>
                                </tr>
                            </#list>
                        </#if>

                    </tbody>
                </table>
                <div class="tab-add-line" id="family">添加家庭成员信息</div>
            </div>
            <div class="wxyy-tab-add">
                <div class="wxyy-tab-list-tit">初中阶段考试成绩情况（注明：请注明初三最近两次考试成绩）</div>
                <table cellpadding="0" cellspacing="0" width="100%" class="wxyy-table" id="test">
                    <thead>
                    <tr>
                        <th>考试成绩</th>
                        <th>语文</th>
                        <th>数学</th>
                        <th>英语</th>
                        <th>物理</th>
                        <th>化学</th>
                        <th>政治</th>
                        <th>历史</th>
                        <th>总分</th>
                        <th>班级名次</th>
                        <th>年级名次</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                        <#if (testList?? && (testList?size>0))>
                            <#list testList as tList>
                                <tr>
                                <input type="hidden" value="${tList.id}">
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off"   name="name" value="${tList.name}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off" lay-verify="digital" name="chinese" value="${tList.chinese}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off" lay-verify="digital" name="math" value="${tList.math}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off" lay-verify="digital" name="english" value="${tList.english}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off"  lay-verify="digital" name="physical" value="${tList.physical}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off" lay-verify="digital" name="chemistry" value="${tList.chemistry}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off" lay-verify="digital" name="politicial" value="${tList.politicial}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off" lay-verify="digital" name="history" value="${tList.history}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off" lay-verify="digital" name="totalScore" value="${tList.totalScore}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off" lay-verify="digital" name="classRank" value="${tList.classRank}"></td>
                                <td><input type="text" class="wxyy-tab-input" placeholder="请输入" autocomplete="off" lay-verify="digital" name="gradeRank" value="${tList.gradeRank}"></td>
                                <td><div class="operate-btn-ctn"><a class="delebtn"  onclick="delTr(this)">删除</a></div></td>
                                </tr>
                            </#list>
                        </#if>
                    </tbody>
                </table>
                <div class="tab-add-line" id="gradelist">添加成绩信息</div>
            </div>
            <div class="wxyy-tab-list-tit">奖惩情况</div>
            <table class="wxyy-item-table" cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td rowspan="3">初中各方面获奖情况</td>
                    <td rowspan="3"><textarea placeholder="请输入" class="wxyy-tab-textarea" name="reward" id="reward" autocomplete="off" value="${enrollmentStuinfo.reward}">${enrollmentStuinfo.reward}</textarea></td>
                </tr>
                <table>
                    <!--<div class="layui-input-block" style="margin-left: 0px !important;text-align: center;margin-top: 30px; margin-bottom: 50px;">-->
                        <!--<button class="layui-btn layui-btn-normal wxyy-tab-btn" lay-submit="" lay-filter="submitBtn">提交</button>-->
                        <!--<button type="button" id="cancel" class="layui-btn layui-btn-primary wxyy-tab-btn">取消</button>-->
                    <!--</div>-->

                    <div class="layui-form-item">
                        <div class="layui-input-block" style="margin-left: 0px !important;text-align: center">
                            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="submitBtn">提交</button>
                            <button type="button" id="cancel" class="layui-btn layui-btn-primary">取消</button>
                        </div>
                    </div>
                </table>
            </table>

        </div>
        </form>
    </div>
</div>
<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
    var menuId='${parentMenuId}';
    var releaseId='${releaseId}';
    layui.use(['jquery', 'form', 'page', 'dialog', 'laydate', 'fileUtil', 'baseutil'], function () {
        var $ = layui.jquery,
            form = layui.form,
            page = layui.page,
            dialog = layui.dialog,
            laydate = layui.laydate,
            fileUtil = layui.fileUtil,
            baseutil = layui.baseutil;
        //初始化附件控件
        fileUtil.uploadImage('pic', "work/site/mult", '${enrollmentStuinfo.pic}');

        page.initDict('sexType,politicalStatus,nationality,accountType', function (dictData) {
            page.showDict($("#sex"), page.aceeptDictContentList(dictData, 'sexType'), "请选择", '${enrollmentStuinfo.sex}');
            page.showDict($("#politicalStatus"), page.aceeptDictContentList(dictData, 'politicalStatus'), "请选择", '${enrollmentStuinfo.politicalStatus}');
            page.showDict($("#nationality"), page.aceeptDictContentList(dictData, 'nationality'), "请选择", '${enrollmentStuinfo.nationality}');
            page.showDict($("#accountType"), page.aceeptDictContentList(dictData, 'accountType'), "请选择", '${enrollmentStuinfo.accountType}');
        });

        //提交校验
        form.verify({
            phone: [/^1\d{10}$/, "请输入正确的手机号"],
            digital:[/^\+?[1-9][0-9]*$/,"人数，分数请填写正整数"],
            card: [/(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
        });

        //监听提交
        form.on('submit(submitBtn)', function (data) {
            var  homeArr=[];
            var  testArr=[];
            $("#home tbody tr").each(function (obj, index) {
                obj = {};
                var name = $(this).find("input[name='name']").val();
                var title = $(this).find("input[name='title']").val();
                var workPlace = $(this).find("input[name='workPlace']").val();
                var position = $(this).find("input[name='position']").val();
                var phone = $(this).find("input[name='phone']").val();
                obj.name = name;
                obj.title = title;
                obj.workPlace = workPlace;
                obj.position=position;
                obj.phone=phone;
                homeArr.push(obj);
            });
            $("#test tbody tr").each(function(objnew,index){
                objnew={};
                var name = $(this).find("input[name='name']").val();
                var chinese = $(this).find("input[name='chinese']").val();
                var math = $(this).find("input[name='math']").val();
                var english = $(this).find("input[name='english']").val();
                var physical = $(this).find("input[name='physical']").val();
                var chemistry = $(this).find("input[name='chemistry']").val();
                var politicial = $(this).find("input[name='politicial']").val();
                var history = $(this).find("input[name='history']").val();
                var totalScore = $(this).find("input[name='totalScore']").val();
                var classRank = $(this).find("input[name='classRank']").val();
                var gradeRank = $(this).find("input[name='gradeRank']").val();
                objnew.name=name;
                objnew.chinese=chinese;
                objnew.math=math;
                objnew.english=english;
                objnew.physical=physical;
                objnew.chemistry=chemistry;
                objnew.politicial=politicial;
                objnew.history=history;
                objnew.totalScore=totalScore;
                objnew.classRank=classRank;
                objnew.gradeRank=gradeRank;
                testArr.push(objnew);
            });
            data.field.id = '${enrollmentStuinfo.id}';
            data.field.homeInfo=JSON.stringify(homeArr);
            data.field.testInfo=JSON.stringify(testArr);
            data.field.releaseId=releaseId;
            var pic=$('input[name=pic]').val();
            if(isBlank(pic)){
                dialog.msg("请上传一寸照片！");
                return false;
            }
            baseutil.post("/enrollment/enrollmentstuinfo/addOrUpdate", data.field, function (res) {
                if(res.code=='0'){
                    $("#save").click();
                    parent.tabRefresh(menuId);
                    parent.tabDelete('enrollmentStuinfoEdit');
                }else{
                    dialog.msg(res.msg);
                    return false;
                }
            });
            return false;
        });

        $("#cancel").on("click",function () {
            parent.tabDelete('enrollmentStuinfoEdit');
        });

        $("#family").bind("click",function(){
            console.log(1);
            var str='<tr>' +
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" name="name" placeholder="请输入"></td>' +
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off"  name="title" placeholder="请输入"></td>' +
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" name="workPlace" placeholder="请输入"></td>' +
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" name="position" placeholder="请输入"></td>' +
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" lay-verify="phone" name="phone" placeholder="请输入"></td>' +
                '<td><div class="operate-btn-ctn"><a class="delebtn" onclick="delTr(this)">删除</a></div></td>' +
                '</tr>';
            $(this).parents(".wxyy-tab-add").find("table").find("tbody").append(str);
        });

        $("#gradelist").bind("click",function(){
            console.log(2);
            var str='<tr>' +
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" name="name" placeholder="请输入"></td>'+
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" lay-verify="digital" name="chinese" placeholder="请输入"></td>'+
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" lay-verify="digital" name="math" placeholder="请输入"></td>'+
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" lay-verify="digital" name="english" placeholder="请输入"></td>'+
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" lay-verify="digital" name="physical" placeholder="请输入"></td>'+
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" lay-verify="digital" name="chemistry" placeholder="请输入"></td>'+
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" lay-verify="digital" name="politicial" placeholder="请输入"></td>'+
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" lay-verify="digital" name="history" placeholder="请输入"></td>'+
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" lay-verify="digital" name="totalScore" placeholder="请输入"></td>'+
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" lay-verify="digital" name="classRank" placeholder="请输入"></td>'+
                '<td><input type="text" class="wxyy-tab-input" autocomplete="off" lay-verify="digital" name="gradeRank" placeholder="请输入"></td>'+
                '<td><div class="operate-btn-ctn"><a class="delebtn" onclick="delTr(this)">删除</a></div></td>'+
                '</tr>';
            $(this).parents(".wxyy-tab-add").find("table").find("tbody").append(str);
        });
    });
    function delTr(obj){
        $(obj).parent().parent().parent().remove();
    }

</script>
</body>
</html>